<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of mlpff</title>
  <meta name="keywords" content="mlpff">
  <meta name="description" content="MLPFF  Calculates the output of a ReBEL feed-forward MLP neural network with 2,3 or 4 layers">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../menu.html">Home</a> &gt;  <a href="#">ReBEL-0.2.7</a> &gt; <a href="#">core</a> &gt; mlpff.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../menu.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="menu.html">Index for .\ReBEL-0.2.7\core&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>mlpff
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>MLPFF  Calculates the output of a ReBEL feed-forward MLP neural network with 2,3 or 4 layers</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function Y = mlpff(olType, nodes, X, W1, B1, W2, B2, W3, B3, W4, B4) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> MLPFF  Calculates the output of a ReBEL feed-forward MLP neural network with 2,3 or 4 layers

   Y = mlpff(olType, nodes, X, W1, )

   INPUT
          olType        output layer type :  'lin' (linear) or 'tanh' (hyperbolic tangent)
          nodes         neural network layer descriptor vector [num_in num_hid1 (num_hid2) (num_hid3) num_out]
          X             neural network inputs (xdim-by-M matrix where M is the number of input vectors)
          Wi            i'th layer weight matrix
          Bi            i'th layer bias vector

   OUTPUT
          Y             neural network output (ydim-by-M matrix)

   NOTE : The neural network parameters (weights and biases) can be passed into this function either as seperate
          unpacked weight and bias matrices (Wi and Bi), or as a single packed vector of parameters (which will be
          unpacked internally). For the second option 'W1' should be used as the input argument containing the
          parameter vector.

   Copyright (c) Oregon Health &amp; Science University (2006)

   This file is part of the ReBEL Toolkit. The ReBEL Toolkit is available free for
   academic use only (see included license file) and can be obtained from
   http://choosh.csee.ogi.edu/rebel/.  Businesses wishing to obtain a copy of the
   software should contact rebel@csee.ogi.edu for commercial licensing information.

   See LICENSE (which should be part of the main toolkit distribution) for more
   detail.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="cvecrep.html" class="code" title="function m = cvecrep(v,c)">cvecrep</a>	CVECREP  Column vector replicate</li><li><a href="mlpunpack.html" class="code" title="function [W1, B1, W2, B2, W3, B3, W4, B4] = mlpunpack(nodes, wh)">mlpunpack</a>	MLPUNPACK  ReBEL MLP neural network weight matrices de-vectorizer.</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="../.././ReBEL-0.2.7/examples/gssm/infds_train_nn.html" class="code" title="function InferenceDS = infds_train_nn">infds_train_nn</a>	INFDS_TRAIN_NN  Demonstrate how the ReBEL toolkit is used to train a neural network</li><li><a href="../.././ReBEL-0.2.7/examples/parameter_estimation/dempe2.html" class="code" title="">dempe2</a>	DEMPE2  Demonstrate how the ReBEL toolkit is used to train a neural network</li></ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function Y = mlpff(olType, nodes, X, W1, B1, W2, B2, W3, B3, W4, B4)</a>
0002 
0003 <span class="comment">% MLPFF  Calculates the output of a ReBEL feed-forward MLP neural network with 2,3 or 4 layers</span>
0004 <span class="comment">%</span>
0005 <span class="comment">%   Y = mlpff(olType, nodes, X, W1, )</span>
0006 <span class="comment">%</span>
0007 <span class="comment">%   INPUT</span>
0008 <span class="comment">%          olType        output layer type :  'lin' (linear) or 'tanh' (hyperbolic tangent)</span>
0009 <span class="comment">%          nodes         neural network layer descriptor vector [num_in num_hid1 (num_hid2) (num_hid3) num_out]</span>
0010 <span class="comment">%          X             neural network inputs (xdim-by-M matrix where M is the number of input vectors)</span>
0011 <span class="comment">%          Wi            i'th layer weight matrix</span>
0012 <span class="comment">%          Bi            i'th layer bias vector</span>
0013 <span class="comment">%</span>
0014 <span class="comment">%   OUTPUT</span>
0015 <span class="comment">%          Y             neural network output (ydim-by-M matrix)</span>
0016 <span class="comment">%</span>
0017 <span class="comment">%   NOTE : The neural network parameters (weights and biases) can be passed into this function either as seperate</span>
0018 <span class="comment">%          unpacked weight and bias matrices (Wi and Bi), or as a single packed vector of parameters (which will be</span>
0019 <span class="comment">%          unpacked internally). For the second option 'W1' should be used as the input argument containing the</span>
0020 <span class="comment">%          parameter vector.</span>
0021 <span class="comment">%</span>
0022 <span class="comment">%   Copyright (c) Oregon Health &amp; Science University (2006)</span>
0023 <span class="comment">%</span>
0024 <span class="comment">%   This file is part of the ReBEL Toolkit. The ReBEL Toolkit is available free for</span>
0025 <span class="comment">%   academic use only (see included license file) and can be obtained from</span>
0026 <span class="comment">%   http://choosh.csee.ogi.edu/rebel/.  Businesses wishing to obtain a copy of the</span>
0027 <span class="comment">%   software should contact rebel@csee.ogi.edu for commercial licensing information.</span>
0028 <span class="comment">%</span>
0029 <span class="comment">%   See LICENSE (which should be part of the main toolkit distribution) for more</span>
0030 <span class="comment">%   detail.</span>
0031 
0032 <span class="comment">%=============================================================================================</span>
0033 
0034 nArgIn = nargin;              <span class="comment">% number of input arguments</span>
0035 nLayers = length(nodes)-1;    <span class="comment">% number of neural network layers</span>
0036 nInpVecs = size(X,2);         <span class="comment">% number of input vectors</span>
0037 
0038 <span class="keyword">if</span> (nArgIn==4)                <span class="comment">% unpack weights and biases if needed</span>
0039     <span class="keyword">switch</span> nLayers
0040       <span class="keyword">case</span> 2
0041           [W1, B1, W2, B2] = <a href="mlpunpack.html" class="code" title="function [W1, B1, W2, B2, W3, B3, W4, B4] = mlpunpack(nodes, wh)">mlpunpack</a>(nodes, W1);
0042       <span class="keyword">case</span> 3
0043           [W1, B1, W2, B2, W3, B3] = <a href="mlpunpack.html" class="code" title="function [W1, B1, W2, B2, W3, B3, W4, B4] = mlpunpack(nodes, wh)">mlpunpack</a>(nodes, W1);
0044       <span class="keyword">case</span> 4
0045           [W1, B1, W2, B2, W3, B3, W4, B4] = <a href="mlpunpack.html" class="code" title="function [W1, B1, W2, B2, W3, B3, W4, B4] = mlpunpack(nodes, wh)">mlpunpack</a>(nodes, W1);
0046       <span class="keyword">otherwise</span>
0047           error(<span class="string">' [ mlpff ] Only 2, 3 and 4 layer networks supported.'</span>);
0048     <span class="keyword">end</span>
0049 <span class="keyword">end</span>
0050 
0051 
0052 <span class="comment">%-- if &gt;= 2 layers</span>
0053 
0054 Y = W2*tanh(W1*X + <a href="cvecrep.html" class="code" title="function m = cvecrep(v,c)">cvecrep</a>(B1,nInpVecs)) + <a href="cvecrep.html" class="code" title="function m = cvecrep(v,c)">cvecrep</a>(B2,nInpVecs);
0055 
0056 <span class="comment">%-- if &gt; 2 layers</span>
0057 <span class="keyword">if</span> (nLayers &gt; 2)
0058     Y = W3*tanh(Y) + <a href="cvecrep.html" class="code" title="function m = cvecrep(v,c)">cvecrep</a>(B3,nInpVecs);
0059 <span class="keyword">end</span>
0060 
0061 <span class="comment">%-- if &gt; 3 layers</span>
0062 <span class="keyword">if</span> (nLayers &gt; 3)
0063     Y = W4*tanh(Y) + <a href="cvecrep.html" class="code" title="function m = cvecrep(v,c)">cvecrep</a>(B4,nInpVecs);
0064 <span class="keyword">end</span>
0065 
0066 
0067 <span class="keyword">switch</span> olType
0068   <span class="keyword">case</span> <span class="string">'lin'</span>
0069   <span class="keyword">case</span> <span class="string">'tanh'</span>
0070       Y=tanh(Y);
0071   <span class="keyword">otherwise</span>
0072       error(<span class="string">' [ mlpff ] Output layer type unknown. Only &quot;lin&quot; (linear) and &quot;tanh&quot; (hyperbolic tangent) supported.'</span>);
0073 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Tue 26-Sep-2006 10:36:21 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>